# 若若今天碰到了一道难题，难题是这样的，
# 对于所有的小于等于n的a，b，且a和b不能相等，求出所有这些a和b的最大公约数，
# 我们记g(n)为这些最大公约数的最大值，
# 现在需要你求出g(2)*g(2)+ g(3)*g(3) + g(4)*g(4) + ... + g(2*n+1)*g(2*n+1)
# 样例解释
# 如n=3，需求出g(2)*g(2)+ g(3)*g(3) + g(4)*g(4) + ... + g(7)*g(7)
# g(2) = 1, [1,2]
# g(3) = 1, [1,2,3]
# g(4) = 2, [1,2,3,4]
# g(5) = 2, [1,2,3,4,5]
# g(6) = 3, [1,2,3,4,5,6]
# g(7) = 3, [1,2,3,4,5,6,7]
# g(8) = 4, [1,2,3,4,5,6,7,8]
# 1*1+1*1+2*2+2*2+3*3+3*3=28

s = input()
if s != '':
    N = int(s)
    if N >= 2:
        sum_value = 0
        for i in range(2, 2 * N + 2):
            temp = i//2
            sum_value += temp * temp
        print(int(sum_value)%10007)

